package com.vlin.scene.actuator;

import com.vlin.entity.scene.Automation;
import com.vlin.entity.scene.Scene;
import com.vlin.entity.scene.TimerEvent;

public abstract class AbstractSceneResolver implements SceneResolver {

	private ListCommandProducer listCommandProducer;
	
	@Override
	public boolean support(Scene scene) {

		if(scene != null)
			return false;
		return doSupport(scene);
	}
	
	abstract public boolean doSupport(Scene scene);

	@Override
	public TimerEvent resolve(Scene scene) {

		if(support(scene)) {
			return doResolve(scene);
		}
		return null;
	}
	
	abstract public TimerEvent doResolve(Scene scene);

	
	@Override
	public void setListCommandProducer(ListCommandProducer listCommandProducer) {
		if(listCommandProducer != null) {
			this.listCommandProducer = listCommandProducer;
		}
		
	}
	
	@Override
	public boolean support(Automation automation) {
		if(automation == null)
			return false;
		return doSupport(automation);
	}
	
	abstract public boolean doSupport(Automation automation);

	@Override
	public TimerEvent resolve(Automation automation) {
		if(!support(automation))
			return null;
		return doResolve(automation);
	}
	
	abstract public TimerEvent doResolve(Automation automation);

	@Override
	public ListCommandProducer getListCommandProducer() {
		
		return this.listCommandProducer;
	}

	@Override
	public void addCommandProducer(CommandProducer commandProducer) {
		this.listCommandProducer.addCommandProducer(commandProducer);
		
		
	}
}
